package com.mxwl.cbg.common.conversion;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;

import java.io.IOException;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;

public class EpochMillisToLocalDateTimeDeserializer extends JsonDeserializer<ZonedDateTime> {


    @Override
    public ZonedDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
        long epochMilli = p.getValueAsLong();
        return ZonedDateTime.ofInstant(Instant.ofEpochMilli(epochMilli), ZoneId.of("Asia/Shanghai"));
    }
}